/**
 * 
 */
package org.openwork.portlet.skills.action;

import javax.servlet.http.HttpServletRequest;

import org.openwork.portlet.action.BaseAction;
import org.openwork.portlet.skillmanagement.model.SkillCategory;
import org.openwork.portlet.skillmanagement.service.SkillCategoryLocalServiceUtil;

import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.Validator;

/**
 * @author samuelgmartinez
 *
 */
public class EditSkillCategoryAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7492745921862030390L;

	@Override
	public String execute() throws Exception {
		HttpServletRequest request = getServletRequest();
		String categoryId = ParamUtil.get(request, WebKeys.SKILL_CAT_ID_PARAM, StringPool.BLANK);
		
		if(Validator.isNotNull(categoryId) && Validator.isNumber(categoryId)) {
			SkillCategory category = SkillCategoryLocalServiceUtil.getSkillCategory(GetterUtil.getLong(categoryId));
			
			request.setAttribute(WebKeys.SKILL_CAT_ATTR, category);
		}
		
		return SUCCESS;
	}
	
}
